var evaluateVue = new Vue({
	el: "#app",
	data: {
		size: 5,
		pics: [],
		orderNo: "",
		products: [],
		type: "",
		content: ""
	},
	methods: {
		upload: function(event) {
			var file = event.target.files;
			wx.showLoading({
				title: "上传中..."
			});
			var formData = new FormData();
			formData.append("file", file[0]);
			this.$http.post(baseUrl + "user/uploadImg", formData).then(function(e) {
				wx.hideLoading();
				var content = e.data;
				if (content.success) {
					this.pics.push(content.data);
				} else {
					wx.showToast({
						title: content.description,
						icon: "none",
						duration: 2e3,
						mask: !1
					});
				}
			});
		},
		addPicButton: function() {
			this.$refs.addPic.dispatchEvent(new MouseEvent('click'));
		},
		submit: function() {
			if ("" == this.content.trim()) return wx.showToast({
				title: "请填写评论",
				icon: "none",
				duration: 2e3,
				mask: !0
			}), !1;
			if (!/\S{15}/.test(this.content)) return wx.showToast({
				title: "评价不能少于15字哦~",
				icon: "none",
				duration: 2e3,
				mask: !0
			}), !1;
			wx.showLoading({
				title: "评价中..."
			});
			var userData = JSON.parse(localStorage.getItem("user_data"));
			var t = this;
			t.products.forEach(function(e, index) {
				t.$http.post(baseUrl + "eval/add", {
					orderNo: t.orderNo,
					productGuid: e.guid,
					nickName: userData.nickname,
					photoPath: userData.avatar,
					modelName: e.modelName,
					goodCount: e.count,
					score: t.size,
					path: t.pics.join(","),
					content: t.content,
					type: t.type
				}).then(function(d) {
					if (index == t.products.length - 1) {
						wx.hideLoading();
						Jump.to(page.eval.result, "orderNo=" + t.orderNo);
					}
				});
			});
		}

	},
	created: function() {
		this.orderNo = URLParam.get("orderNo");
		this.products = JSON.parse(URLParam.get("products"));
		this.type = URLParam.get("type");
	}
});
